home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 July / macformat-092.iso / Dreamweaver 3 / Configuration / Commands / Source Formatting.js < prev    next >
Encoding:
Text File  |  1999-12-01  |  1.1 KB  |  45 lines

  1. // Copyright 1998 Macromedia, Inc. All rights reserved.
  2. //-----------------------------------------------------
  3. //
  4. // Source Formatting.js
  5. //
  6. // This file contains the implementation to fire off the Dreamweaver
  7. // source formatter.
  8.  
  9. function canAcceptCommand()
  10. {
  11.   return (dw.getFocus() == 'document');
  12. }
  13.  
  14. // formatSource()
  15. //
  16. // This routine kicks off the Dreamweaver source formatter
  17. // on the entire document by "touching" the HTML child tag
  18. // outerHTML properties.
  19. // 
  20. function formatSource()
  21. {
  22.    var root      = dreamweaver.getDocumentDOM("document");
  23.    var children  = root.childNodes;
  24.    var nChildren = children.length;
  25.  
  26.    // Go one level below HTML tag -- the outerHTML property
  27.    // on the HTML tag has slightly different update semantics
  28.    // that the rest of the objects in the tree
  29.    //
  30.    for( var i = 0; i < nChildren; i++ )
  31.    {
  32.       var child = children.item(i);
  33.       if ( child.hasChildNodes() )
  34.       {
  35.          var subChildren  = child.childNodes;
  36.          var nSubChildren = subChildren.length;
  37.          
  38.          for( var j = 0; j < nSubChildren; j++ )
  39.             subChildren.item(j).outerHTML += "";
  40.       }
  41.    }
  42.    
  43.    return;         
  44. }
  45.